#ifndef DRAWTREE_H
#define DRAWTREE_H
extern pointarray nodep;
extern node *root;
extern int maxNumOfIter;
extern double maxchange;
extern double maxx;
extern double minx;
extern double maxy;
extern double miny;
extern boolean nbody;
extern int nextnode;
extern boolean uselengths;
extern boolean improve;
extern double treeangle;
extern double ark;
extern char fontname[FONT_NAME_LEN];
extern labelorient labeldirec;
extern double labelrotation;
extern double *textlength, *firstlet;
extern double labelheight;
extern double charht;
extern double topoflabels;
extern double bottomoflabels;
extern double rightoflabels;
extern double leftoflabels;
extern boolean rescaled;
extern double bscale;
extern growth grows;
extern double expand;
extern double xmargin;
extern double xsize;
extern double bscale;
extern double ymargin;
extern double ysize;
extern double xunitspercm;
extern double yunitspercm;
extern double xscale;
extern double yscale;
extern double xoffset;
extern double yoffset;
extern double paperx;
extern double papery;
extern double pagex;
extern double pagey;
extern boolean regular;
extern plottertype plotter;
extern double hpmargin;
extern double vpmargin;
extern boolean labelavoid;
extern boolean haslengths;
extern node *grbg;
extern node *where;
extern char inTreePath[FILE_NAME_LEN];
extern char plotFilePath[FILE_NAME_LEN];
extern boolean goteof;
extern FILE *plotfile;
extern FILE *intree;
extern int numlines;
extern boolean rotate;
struct stackElem
{
  /* This is actually equivalent to a reversed link list; pStackElemBack
     point toward the direction of the bottom of the stack */
  struct stackElem *pStackElemBack;
  node *pNode;
};
typedef struct stackElem stackElemType;
enum { yes, no } penchange, oldpenchange;
void leftRightLimits(node *pToSubNode, double *pLeftLimit, 
	double *pRightLimit);
double forcePerpendicularOnNode(node *pPivotSubNode, node *pToSubNode,
	double medianDistance);
void tilttrav(node *q, double *xx, double *yy, double *sinphi,
	double *cosphi);
void polarizeABranch(node *pStartingSubNode, double *xx, double *yy);
double medianOfDistance(node *pRootSubNode, boolean firstRecursiveCallP);
void pushNodeToStack(stackElemType **ppStackTop, node *pNode);
void popNodeFromStack(stackElemType **ppStackTop, node **ppNode);
void leftrightangle(node *p, double xx, double yy);
void polarize(node *p, double *xx, double *yy);
void plrtrans(node *p, double theta, double lower, double upper);
void polartrav(node *p, double xx, double yy, double firstx,
    double firsty, double *leftx, double *lefty, double *rightx,
	double *righty);
void totalForceOnNode(node *pPivotSubNode, node *pToSubNode,
	double *pTotalForce, double *pAngle, double medianDistance);
double signOfMoment(double xReferenceVector, double yReferenceVector,
                double xForce, double yForce);
#endif
